package com.iuie.ns.system.vo.authority;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.iuie.ns.system.vo.resource.SysResourceVO;
import com.iuie.ns.system.vo.role.SysRoleVO;

/**
 * 权限
 * 
 * @author lj
 * @createTime 2017年1月1日 下午6:24:34
 */
@Table(name="SYS_AUTHORITY")
@Entity
public class SysAuthorityVO {

	@Column(name="authority_id",length=32)
	@Id
	private String authorityId; // 权限ID
	
	@Column(name="AUTHORITY_CODE",unique=true,nullable=false)
	private String authorityCode; // 权限编码
	
	@Column(name="AUTHORITY_NAME")
	private String authorityName; // 权限名称
	
	@Column(name="AUTHORITY_DESC")
	private String authorityDesc; // 权限描述
	
	@ManyToMany(mappedBy="authoritys",cascade=CascadeType.DETACH)
	private Set<SysRoleVO> roles = new HashSet<SysRoleVO>(); // 拥有权限的角色
	
	@JoinColumn(name="resId")
	@ManyToOne(fetch=FetchType.LAZY)
	private SysResourceVO resouce; // 权限和资源是多对一的关联关系

	public String getAuthorityId() {
		return authorityId;
	}

	public void setAuthorityId(String authorityId) {
		this.authorityId = authorityId;
	}

	public String getAuthorityCode() {
		return authorityCode;
	}

	public void setAuthorityCode(String authorityCode) {
		this.authorityCode = authorityCode;
	}

	public String getAuthorityName() {
		return authorityName;
	}

	public void setAuthorityName(String authorityName) {
		this.authorityName = authorityName;
	}

	public String getAuthorityDesc() {
		return authorityDesc;
	}

	public void setAuthorityDesc(String authorityDesc) {
		this.authorityDesc = authorityDesc;
	}

	public Set<SysRoleVO> getRoles() {
		return roles;
	}
	public void setRoles(Set<SysRoleVO> roles) {
		this.roles = roles;
	}
	public SysResourceVO getResouce() {
		return resouce;
	}
	public void setResouce(SysResourceVO resouce) {
		this.resouce = resouce;
	}

}
